package com.nbgroup.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.nbgroup.pojo.RoleMenu;
import com.nbgroup.pojo.vo.MenuTreeselectVO;
import com.nbgroup.pojo.vo.MenuVo;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface MenuMapper extends BaseMapper<MenuVo> {

    List<MenuVo> allList(String menuName, Integer status);

@Select("select *from menu where menu_id=#{menuId}")
    MenuVo selectId(Integer menuId);

    /**
     * 查询全部菜单权限
     * @return
     */
    @Select("select menu_id,menu_name from menu")
    List<MenuTreeselectVO> queryAllMenuS();
    /**
     * 根据roleId添加menu
     */
    @Insert("insert into role_menu(role_id,menu_id) values (#{roleId},#{menuId})")
    void addRoleMenu(RoleMenu roleMenu);

    /**
     * 根据roleId查询menu
     * @param roleId
     * @return
     */
    @Select("select menu_id from role_menu where role_id=#{roleId}")
    List<Integer> queryMenuByRole(Long roleId);

    /**
     * 根据角色id删除菜单权限
     * @param roleId
     */
    @Delete("delete from role_menu where role_id=#{roleId}")
    void daleteRoleMenu(Long roleId);
}
